package com.hnas.eCard.dao.impl;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Component;

import com.hnas.core.dao.BaseDaoImpl;
import com.hnas.eCard.dao.ECardChannelInfoDao;
import com.hnas.eCard.orm.ECardChannelInfo;

@Component("eCardChannelInfoDao")
public class ECardChannelInfoDaoImpl extends BaseDaoImpl<ECardChannelInfo> implements ECardChannelInfoDao{

	public ECardChannelInfoDaoImpl() {
		super(ECardChannelInfo.class);
	}

	@Override
	public ECardChannelInfo findById(String id) {
		return this.find(id);
	}

	@Override
	public ECardChannelInfo findByChannelCode(String channelCode) {
		String hql = "from ECardChannelInfo t where t.channelCode = ?1";
		Query query = this.entityManager.createQuery(hql);
		query.setParameter(1, channelCode);
		List<ECardChannelInfo> resultList = query.getResultList();
		if(resultList != null && resultList.size() > 0) return resultList.get(0);
		return null;
	}

}
